package com.iolo.flinklog.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author fengxinxin
 * @date 2021/4/1
 **/
@Slf4j
@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping("/log")
    public String testLog(@RequestParam("level") String level, @RequestParam("count") Integer count) {
        switch (level) {
            case "info":
                for (int i = 0; i < count; i++) {
                    log.info("info");
                }
                break;
            case "warn":
                for (int i = 0; i < count; i++) {
                    log.warn("warn");
                }
                break;
            case "debug":
                for (int i = 0; i < count; i++) {
                    log.debug("debug");
                }
                break;
            case "error":
                for (int i = 0; i < count; i++) {
                    log.error("error");
                }
                break;
            default:
                log.info("default");
        }
        return "OK!";
    }
}
